<template>
  <div class="home-page">
    <!-- 顶部横幅 -->
    <div class="top">
      <img src="@/assets/images/home.jpg" alt="校园生活圈" class="loading" />
    </div>
    
    <!-- 功能菜单 -->
    <div class="main">
      <div class="list">
        <div 
          v-for="item in menuItems" 
          :key="item.name"
          class="item shadow-project"
          @click="navigateTo(item.path)"
        >
          <img :src="item.icon" :alt="item.name" />
          <div class="title">{{ item.name }}</div>
        </div>
      </div>
      <div style="height: 100px;"></div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { useAppStore } from '@/stores/app'

const router = useRouter()
const appStore = useAppStore()

// 设置页面标题
appStore.setTitle('校园生活圈')

// 菜单项配置 - 完全按照原小程序
const menuItems = ref([
  {
    name: '表白墙',
    path: '/board',
    icon: '/images/menu/board.png'
  },
  {
    name: '失物招领',
    path: '/lost',
    icon: '/images/menu/lost.png'
  },
  {
    name: '兼职招聘',
    path: '/job',
    icon: '/images/menu/job.png'
  },
  {
    name: '二手交易',
    path: '/trade',
    icon: '/images/menu/leave.png'
  },
  {
    name: '个人中心',
    path: '/my',
    icon: '/images/menu/my.png'
  },
  {
    name: '关于我们',
    path: '/about',
    icon: '/images/menu/about.png'
  }
])

// 导航到指定页面
const navigateTo = (path: string) => {
  router.push(path)
}
</script>

<style scoped>
/* 完全按照原小程序样式 */
.home-page {
  background-color: #f8f8f8;
  min-height: 100vh;
}

.main {
  width: 100%;
  padding: 5px 42.5px;
}

.top {
  width: 100%;
}

.top img {
  width: 100%;
  display: block;
}

.list {
  position: relative;
  margin-top: -60px;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  padding: 20px 0;
}

.list .item {
  width: calc((100% - 20px) / 2);
  background-image: linear-gradient(185deg, #dcddf1, #fff);
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 22.5px 0;
  margin-bottom: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.list .item:nth-child(2n+1) {
  margin-right: 20px;
}

.list .item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.list .item img {
  width: 35px;
  height: 40px;
  object-fit: contain;
}

.list .item .title {
  font-size: 14px;
  margin-top: 5px;
  color: #333;
}

/* 阴影效果 */
.shadow-project {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 响应式设计 */
@media (max-width: 480px) {
  .main {
    padding: 5px 20px;
  }
  
  .list .item {
    padding: 18px 0;
  }
  
  .list .item img {
    width: 30px;
    height: 35px;
  }
  
  .list .item .title {
    font-size: 12px;
  }
}
</style>